load("@rules_java//java:defs.bzl", "java_library")
load("//:cel_android_rules.bzl", "cel_android_library")

package(
    default_applicable_licenses = [
        "//:license",
    ],
    default_visibility = [
        "//common/ast:__pkg__",
    ],
)

# keep sorted
AST_SOURCES = [
    "CelConstant.java",
    "CelExpr.java",
    "CelExprFormatter.java",
    "CelReference.java",
    "Expression.java",
]

# keep sorted
EXPR_CONVERTER_SOURCES = [
    "CelExprConverter.java",
]

# keep sorted
EXPR_V1ALPHA1_CONVERTER_SOURCES = [
    "CelExprV1Alpha1Converter.java",
]

# keep sorted
EXPR_FACTORY_SOURCES = [
    "CelExprFactory.java",
    "CelExprIdGeneratorFactory.java",
]

# keep sorted
MUTABLE_EXPR_SOURCES = [
    "CelMutableExpr.java",
    "CelMutableExprConverter.java",
]

java_library(
    name = "ast",
    srcs = AST_SOURCES,
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/values",
        "//common/values:cel_byte_string",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "expr_converter",
    srcs = EXPR_CONVERTER_SOURCES,
    tags = [
    ],
    deps = [
        ":ast",
        "//common/values",
        "//common/values:cel_byte_string",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@cel_spec//proto/cel/expr:syntax_java_proto",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

cel_android_library(
    name = "expr_converter_android",
    srcs = EXPR_CONVERTER_SOURCES,
    tags = [
    ],
    deps = [
        ":ast_android",
        "//common/values:cel_byte_string",
        "//common/values:values_android",
        "@cel_spec//proto/cel/expr:checked_java_proto_lite",
        "@cel_spec//proto/cel/expr:syntax_java_proto_lite",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "expr_v1alpha1_converter",
    srcs = EXPR_V1ALPHA1_CONVERTER_SOURCES,
    tags = [
    ],
    deps = [
        ":ast",
        "//common/values",
        "//common/values:cel_byte_string",
        "@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "cel_expr_visitor",
    srcs = ["CelExprVisitor.java"],
    tags = [
    ],
    deps = [
        ":ast",
        "//common:cel_ast",
    ],
)

java_library(
    name = "expr_factory",
    srcs = EXPR_FACTORY_SOURCES,
    tags = [
    ],
    deps = [
        ":ast",
        "//common/annotations",
        "//common/values:cel_byte_string",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "mutable_expr",
    srcs = MUTABLE_EXPR_SOURCES,
    tags = [
    ],
    deps = [
        ":ast",
        "@maven//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "ast_android",
    srcs = AST_SOURCES,
    tags = [
    ],
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/values:cel_byte_string",
        "//common/values:values_android",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)
